/**
 * Created by Yixin on 2017/8/13.
 */
define([
    "app"
], function (app) {
    app.config([
        "$stateProvider", "$urlRouterProvider",
        function ($stateProvider, $urlRouterProvider) {
            var baseUrl = pageTemplateUrl;

            $urlRouterProvider
                .when("/main/team-in", "/main/team-in/select-room")
                .otherwise("/main/index");

            $stateProvider
                .state("main", {
                    url: "/main",
                    templateUrl: baseUrl + "main.html"
                })
                .state("main.index", {
                    url: "/index",
                    templateUrl: baseUrl + "index.html",
                    controller: "indexController"
                })
                .state("main.manage-register", {
                    url: "/manage-register",
                    templateUrl: baseUrl + "manage-register.html",
                    controller: "manageRegisterController"
                    // resolve:{
                    //     teams:["manageRegisterDataService",function(manageRegisterDataService) {
                    //       return manageRegisterDataService.getAllRegistration();
                    //     }]
                    // }
                })
                .state("main.team-in", {
                    url: "/team-in",
                    templateUrl: baseUrl + "team-in.html"
                })
                .state("main.team-in.select-room", {
                    url: "/select-room",
                    templateUrl: baseUrl + "select-room.html",
                    controller: "selectRoomController"
                })
                .state("main.team-in.attendance-number", {
                    url:"/attendance-number",
                    templateUrl: baseUrl + "attendance-number.html",
                    controller: "attendanceNumberController"
                })
                .state("main.team-in.sign-file",{
                    url:"/sign-file",
                    templateUrl: baseUrl + "sign-file.html",
                    controller: "signFileController"
                })
                .state("main.middle-term", {
                    url: "/middle-term",
                    templateUrl: baseUrl + "middle-term.html"
                })
                .state("main.final-term", {
                    url: "/final-term",
                    templateUrl: baseUrl + "final-term.html"
                })
                .state("select-seat", {
                    url: "/select-seat",
                    templateUrl: baseUrl + "select-seat.html",
                    controller:"selectSeatController"
                })
                .state("select-seat.room", {
                    url: "/{roomNo}",
                    // 根据参数动态加载模板的方法
                    // 来自 https://stackoverflow.com/questions/33734690/angular-ui-router-dynamic-templateurl
                    // templateProvider: ["$stateParams", "$templateRequest",
                    //     function ($stateParams, $templateRequest) {
                    //         return $templateRequest(baseUrl + "room/" + $stateParams.roomNo + ".html");
                    //     }]
                    templateUrl:function ($stateParams) {
                        return baseUrl + "room/select-seat/" + $stateParams.roomNo + ".html";
                    },
                    controller:"selectSeatRoomController"
                })
                .state("main.manage-teacher",{
                    url:"/manage-teacher",
                    templateUrl: baseUrl + "manage-teacher.html",
                    controller:"manageTeacherController"
                })
        }]);
});